package com.cloudbroker.bcs.platform.dav.middle.util;

import com.cloudbroker.bcs.platform.dav.bizapi.constants.PlugsCodes;
import com.cloudbroker.bcs.platform.dav.bizapi.constants.status.MustLoginStatus;
import com.cloudbroker.bcs.platform.dav.bizapi.constants.status.PlugsStatus;
import com.cloudbroker.bcs.platform.dav.bizapi.constants.type.PlugsChargeModType;
import com.cloudbroker.bcs.platform.dav.bizapi.constants.type.PlugsContentSource;
import com.cloudbroker.bcs.platform.dav.middle.entity.Plugs;
import com.cloudbroker.bcs.platform.dav.middle.entity.PlugsType;

import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

public class PlugsUtil {
    
    private static PlugsUtil instance;
    
    public static PlugsUtil getInstance(){
        if(instance == null){
            instance = new PlugsUtil();
        }
        return instance;
    }
    
    public PlugsUtil(){}
    
    private String creater = "云纪网络"; //开发者
    private String ver = "0.0.1"; //版本号
    private String term_type = "1,2,3,"; //适应终端
    
    
    public List<Plugs> packPlugsDb(Long plugsTypeId){
        List<Plugs> list = new ArrayList<Plugs>();

        //观点
        Plugs saveDb = new Plugs();
        saveDb.setPlugs_type_id(plugsTypeId);
        saveDb.setLink("");
        saveDb.setIcon("");
        saveDb.setName(PlugsCodes.talk.getName());
        saveDb.setDescription("");
        saveDb.setCreater(this.getCreater());
        saveDb.setPrice(BigDecimal.ZERO);
        saveDb.setDiscount_price(BigDecimal.ZERO);
        saveDb.setCharge_mod(PlugsChargeModType.BYCOUNT.getVal());
        saveDb.setCreate_time(new Date());
        saveDb.setPlugs_status(PlugsStatus.SALE.getVal());
        saveDb.setVer(this.getVer());
        saveDb.setCode(PlugsCodes.talk.getCode());
        saveDb.setSort(0L);
        saveDb.setTerm_type(this.getTerm_type());
        saveDb.setMust_login(MustLoginStatus.NO_MUST.getVal());
        saveDb.setBuy_count(0L);
        saveDb.setContent_source(PlugsContentSource.MIDDLE.getVal());
        list.add(saveDb);

        saveDb = new Plugs();
        saveDb.setPlugs_type_id(plugsTypeId);
        saveDb.setLink("");
        saveDb.setIcon("");
        saveDb.setName(PlugsCodes.message.getName());
        saveDb.setDescription("");
        saveDb.setCreater(this.getCreater());
        saveDb.setPrice(BigDecimal.ZERO);
        saveDb.setDiscount_price(BigDecimal.ZERO);
        saveDb.setCharge_mod(PlugsChargeModType.BYDAY.getVal());
        saveDb.setCreate_time(new Date());
        saveDb.setPlugs_status(PlugsStatus.SALE.getVal());
        saveDb.setVer(this.getVer());
        saveDb.setCode(PlugsCodes.message.getCode());
        saveDb.setSort(1L);
        saveDb.setTerm_type(this.getTerm_type());
        saveDb.setMust_login(MustLoginStatus.MUST.getVal());
        saveDb.setBuy_count(0L);
        saveDb.setContent_source(PlugsContentSource.MIDDLE.getVal());
        list.add(saveDb);

        saveDb = new Plugs();
        saveDb.setPlugs_type_id(plugsTypeId);
        saveDb.setLink("");
        saveDb.setIcon("");
        saveDb.setName(PlugsCodes.faq.getName());
        saveDb.setDescription("");
        saveDb.setCreater(this.getCreater());
        saveDb.setPrice(BigDecimal.ZERO);
        saveDb.setDiscount_price(BigDecimal.ZERO);
        saveDb.setCharge_mod(PlugsChargeModType.BYDAY.getVal());
        saveDb.setCreate_time(new Date());
        saveDb.setPlugs_status(PlugsStatus.SALE.getVal());
        saveDb.setVer(this.getVer());
        saveDb.setCode(PlugsCodes.faq.getCode());
        saveDb.setSort(2L);
        saveDb.setTerm_type(this.getTerm_type());
        saveDb.setMust_login(MustLoginStatus.NO_MUST.getVal());
        saveDb.setBuy_count(0L);
        saveDb.setContent_source(PlugsContentSource.MIDDLE.getVal());
        list.add(saveDb);

        saveDb = new Plugs();
        saveDb.setPlugs_type_id(plugsTypeId);
        saveDb.setLink("");
        saveDb.setIcon("");
        saveDb.setName(PlugsCodes.stock.getName());
        saveDb.setDescription("");
        saveDb.setCreater(this.getCreater());
        saveDb.setPrice(BigDecimal.ZERO);
        saveDb.setDiscount_price(BigDecimal.ZERO);
        saveDb.setCharge_mod(PlugsChargeModType.BYDAY.getVal());
        saveDb.setCreate_time(new Date());
        saveDb.setPlugs_status(PlugsStatus.SALE.getVal());
        saveDb.setVer(this.getVer());
        saveDb.setCode(PlugsCodes.stock.getCode());
        saveDb.setSort(3L);
        saveDb.setTerm_type(this.getTerm_type());
        saveDb.setMust_login(MustLoginStatus.MUST.getVal());
        saveDb.setBuy_count(0L);
        saveDb.setContent_source(PlugsContentSource.MIDDLE.getVal());
        list.add(saveDb);

        saveDb = new Plugs();
        saveDb.setPlugs_type_id(plugsTypeId);
        saveDb.setLink("");
        saveDb.setIcon("");
        saveDb.setName(PlugsCodes.news.getName());
        saveDb.setDescription("");
        saveDb.setCreater(this.getCreater());
        saveDb.setPrice(BigDecimal.ZERO);
        saveDb.setDiscount_price(BigDecimal.ZERO);
        saveDb.setCharge_mod(PlugsChargeModType.BYDAY.getVal());
        saveDb.setCreate_time(new Date());
        saveDb.setPlugs_status(PlugsStatus.SALE.getVal());
        saveDb.setVer(this.getVer());
        saveDb.setCode(PlugsCodes.news.getCode());
        saveDb.setSort(4L);
        saveDb.setTerm_type(this.getTerm_type());
        saveDb.setMust_login(MustLoginStatus.MUST.getVal());
        saveDb.setBuy_count(0L);
        saveDb.setContent_source(PlugsContentSource.MIDDLE.getVal());
        list.add(saveDb);

        saveDb = new Plugs();
        saveDb.setPlugs_type_id(plugsTypeId);
        saveDb.setLink("");
        saveDb.setIcon("");
        saveDb.setName(PlugsCodes.diagnoses.getName());
        saveDb.setDescription("");
        saveDb.setCreater(this.getCreater());
        saveDb.setPrice(BigDecimal.ZERO);
        saveDb.setDiscount_price(BigDecimal.ZERO);
        saveDb.setCharge_mod(PlugsChargeModType.BYDAY.getVal());
        saveDb.setCreate_time(new Date());
        saveDb.setPlugs_status(PlugsStatus.SALE.getVal());
        saveDb.setVer(this.getVer());
        saveDb.setCode(PlugsCodes.diagnoses.getCode());
        saveDb.setSort(5L);
        saveDb.setTerm_type(this.getTerm_type());
        saveDb.setMust_login(MustLoginStatus.NO_MUST.getVal());
        saveDb.setBuy_count(0L);
        saveDb.setContent_source(PlugsContentSource.MIDDLE.getVal());
        list.add(saveDb);

        saveDb = new Plugs();
        saveDb.setPlugs_type_id(plugsTypeId);
        saveDb.setLink("");
        saveDb.setIcon("");
        saveDb.setName(PlugsCodes.trade.getName());
        saveDb.setDescription("");
        saveDb.setCreater(this.getCreater());
        saveDb.setPrice(BigDecimal.ZERO);
        saveDb.setDiscount_price(BigDecimal.ZERO);
        saveDb.setCharge_mod(PlugsChargeModType.BYDAY.getVal());
        saveDb.setCreate_time(new Date());
        saveDb.setPlugs_status(PlugsStatus.SALE.getVal());
        saveDb.setVer(this.getVer());
        saveDb.setCode(PlugsCodes.trade.getCode());
        saveDb.setSort(6L);
        saveDb.setTerm_type(this.getTerm_type());
        saveDb.setMust_login(MustLoginStatus.MUST.getVal());
        saveDb.setBuy_count(0L);
        saveDb.setContent_source(PlugsContentSource.MIDDLE.getVal());
        list.add(saveDb);

        return list;
    }

    public List<Plugs> addPlugsDb(Long plugsTypeId){
        List<Plugs> list = new ArrayList<Plugs>();
        Plugs saveDb;
        
        //个股诊断
/*        Plugs saveDb = new Plugs();
        saveDb.setPlugs_type_id(plugsTypeId);
        saveDb.setLink("");
        saveDb.setIcon("");
        saveDb.setName(PlugsCodes.diagnoses.getName());
        saveDb.setDescription("");
        saveDb.setCreater(this.getCreater());
        saveDb.setPrice(BigDecimal.ZERO);
        saveDb.setDiscount_price(BigDecimal.ZERO);
        saveDb.setCharge_mod(PlugsChargeModType.BYDAY.getVal());
        saveDb.setCreate_time(new Date());
        saveDb.setPlugs_status(PlugsStatus.SALE.getVal());
        saveDb.setVer(this.getVer());
        saveDb.setCode(PlugsCodes.diagnoses.getCode());
        saveDb.setSort(5L);
        saveDb.setTerm_type(this.getTerm_type());
        saveDb.setMust_login(MustLoginStatus.NO_MUST.getVal());
        saveDb.setBuy_count(0L);
        list.add(saveDb);

        //模拟炒股
        saveDb = new Plugs();
        saveDb.setPlugs_type_id(plugsTypeId);
        saveDb.setLink("");
        saveDb.setIcon("");
        saveDb.setName(PlugsCodes.trade.getName());
        saveDb.setDescription("");
        saveDb.setCreater(this.getCreater());
        saveDb.setPrice(BigDecimal.ZERO);
        saveDb.setDiscount_price(BigDecimal.ZERO);
        saveDb.setCharge_mod(PlugsChargeModType.BYDAY.getVal());
        saveDb.setCreate_time(new Date());
        saveDb.setPlugs_status(PlugsStatus.SALE.getVal());
        saveDb.setVer(this.getVer());
        saveDb.setCode(PlugsCodes.trade.getCode());
        saveDb.setSort(6L);
        saveDb.setTerm_type(this.getTerm_type());
        saveDb.setMust_login(MustLoginStatus.MUST.getVal());
        saveDb.setBuy_count(0L);
        list.add(saveDb);*/
        
        //猜涨跌
/*        saveDb = new Plugs();
        saveDb.setPlugs_type_id(plugsTypeId);
        saveDb.setLink("");
        saveDb.setIcon("");
        saveDb.setName(PlugsCodes.updown.getName());
        saveDb.setDescription("");
        saveDb.setCreater(this.getCreater());
        saveDb.setPrice(BigDecimal.ZERO);
        saveDb.setDiscount_price(BigDecimal.ZERO);
        saveDb.setCharge_mod(PlugsChargeModType.BYDAY.getVal());
        saveDb.setCreate_time(new Date());
        saveDb.setPlugs_status(PlugsStatus.SALE.getVal());
        saveDb.setVer(this.getVer());
        saveDb.setCode(PlugsCodes.updown.getCode());
        saveDb.setSort(7L);
        saveDb.setTerm_type(this.getTerm_type());
        saveDb.setMust_login(MustLoginStatus.MUST.getVal());
        saveDb.setBuy_count(0L);
        saveDb.setContent_source(PlugsContentSource.OUTSIDE.getVal());
        list.add(saveDb);*/
        
        //策略
        saveDb = new Plugs();
        saveDb.setPlugs_type_id(plugsTypeId);
        saveDb.setLink("");
        saveDb.setIcon("");
        saveDb.setName(PlugsCodes.strategy.getName());
        saveDb.setDescription("");
        saveDb.setCreater(this.getCreater());
        saveDb.setPrice(BigDecimal.ZERO);
        saveDb.setDiscount_price(BigDecimal.ZERO);
        saveDb.setCharge_mod(PlugsChargeModType.BYDAY.getVal());
        saveDb.setCreate_time(new Date());
        saveDb.setPlugs_status(PlugsStatus.SALE.getVal());
        saveDb.setVer(this.getVer());
        saveDb.setCode(PlugsCodes.strategy.getCode());
        saveDb.setSort(8L);
        saveDb.setTerm_type(this.getTerm_type());
        saveDb.setMust_login(MustLoginStatus.MUST.getVal());
        saveDb.setBuy_count(0L);
        saveDb.setContent_source(PlugsContentSource.MIDDLE.getVal());
        list.add(saveDb);
        
        //局外人调研
/*        saveDb = new Plugs();
        saveDb.setPlugs_type_id(plugsTypeId);
        saveDb.setLink("");
        saveDb.setIcon("");
        saveDb.setName(PlugsCodes.outsider.getName());
        saveDb.setDescription("");
        saveDb.setCreater(this.getCreater());
        saveDb.setPrice(BigDecimal.ZERO);
        saveDb.setDiscount_price(BigDecimal.ZERO);
        saveDb.setCharge_mod(PlugsChargeModType.BYDAY.getVal());
        saveDb.setCreate_time(new Date());
        saveDb.setPlugs_status(PlugsStatus.SALE.getVal());
        saveDb.setVer(this.getVer());
        saveDb.setCode(PlugsCodes.outsider.getCode());
        saveDb.setSort(9L);
        saveDb.setTerm_type(this.getTerm_type());
        saveDb.setMust_login(MustLoginStatus.NO_MUST.getVal());
        saveDb.setBuy_count(0L);
        saveDb.setContent_source(PlugsContentSource.MIDDLE.getVal());
        list.add(saveDb);
        
        //投教学院
        saveDb = new Plugs();
        saveDb.setPlugs_type_id(plugsTypeId);
        saveDb.setLink("");
        saveDb.setIcon("");
        saveDb.setName(PlugsCodes.tjxy.getName());
        saveDb.setDescription("");
        saveDb.setCreater(this.getCreater());
        saveDb.setPrice(BigDecimal.ZERO);
        saveDb.setDiscount_price(BigDecimal.ZERO);
        saveDb.setCharge_mod(PlugsChargeModType.BYDAY.getVal());
        saveDb.setCreate_time(new Date());
        saveDb.setPlugs_status(PlugsStatus.SALE.getVal());
        saveDb.setVer(this.getVer());
        saveDb.setCode(PlugsCodes.tjxy.getCode());
        saveDb.setSort(10L);
        saveDb.setTerm_type(this.getTerm_type());
        saveDb.setMust_login(MustLoginStatus.MUST.getVal());
        saveDb.setBuy_count(0L);
        saveDb.setContent_source(PlugsContentSource.OUTSIDE.getVal());
        list.add(saveDb);*/
        
        //趣炒股
        saveDb = new Plugs();
        saveDb.setPlugs_type_id(plugsTypeId);
        saveDb.setLink("");
        saveDb.setIcon("");
        saveDb.setName(PlugsCodes.wonderful.getName());
        saveDb.setDescription("");
        saveDb.setCreater(this.getCreater());
        saveDb.setPrice(BigDecimal.ZERO);
        saveDb.setDiscount_price(BigDecimal.ZERO);
        saveDb.setCharge_mod(PlugsChargeModType.BYDAY.getVal());
        saveDb.setCreate_time(new Date());
        saveDb.setPlugs_status(PlugsStatus.SALE.getVal());
        saveDb.setVer(this.getVer());
        saveDb.setCode(PlugsCodes.wonderful.getCode());
        saveDb.setSort(11L);
        saveDb.setTerm_type(this.getTerm_type());
        saveDb.setMust_login(MustLoginStatus.NO_MUST.getVal());
        saveDb.setBuy_count(0L);
        saveDb.setContent_source(PlugsContentSource.OUTSIDE.getVal());
        list.add(saveDb);

        return list;
    }
    
    public PlugsType packPlugsType(){
        PlugsType plugsType = new PlugsType();
        plugsType.setIcon("");
        plugsType.setName("全部");
        plugsType.setSort(0L);
        plugsType.setLink("");
        plugsType.setPlugs_type_status(1);
        return plugsType;
    }

    public String getTerm_type() {
        return term_type;
    }

    public void setTerm_type(String term_type) {
        this.term_type = term_type;
    }

    public String getCreater() {
        return creater;
    }

    public void setCreater(String creater) {
        this.creater = creater;
    }

    public String getVer() {
        return ver;
    }

    public void setVer(String ver) {
        this.ver = ver;
    }
}
